home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Burning & Media / GB-PVR 1.2.13 / GBPVR10213.msi / Cabs.w1.cab / Details.aspx.cs589 < prev    next >
Text File  |  2008-03-12  |  36KB  |  881 lines

  1. //===========================================================================
  2. // This file was modified as part of an ASP.NET 2.0 Web project conversion.
  3. // The class name was changed and the class modified to inherit from the abstract base class 
  4. // in file 'App_Code\Migrated\Stub_Details_aspx_cs.cs'.
  5. // During runtime, this allows other classes in your web application to bind and access 
  6. // the code-behind page using the abstract base class.
  7. // The associated content page 'Details.aspx' was also modified to refer to the new class name.
  8. // For more information on this code pattern, please refer to http://go.microsoft.com/fwlink/?LinkId=46995 
  9. //===========================================================================
  10. using System;
  11. using System.Collections;
  12. using System.Data.Common;
  13. using System.IO;
  14. using System.Threading;
  15. using System.Web;
  16. using System.Xml;
  17. using GBPVR.Public;
  18. using GBPVRSchedule;
  19. using gbweb.classes;
  20.  
  21. namespace gbweb
  22. {
  23.     /// <summary>
  24.     /// Summary description for Details.
  25.     /// </summary>
  26.     public partial class Migrated_Details : Details
  27.     {
  28.         private Settings guideParams;
  29.         protected string programUniqueIdentifier;
  30.     
  31.         protected void Page_Load(object sender, EventArgs e)
  32.         {
  33.             getTheme();
  34.             guideParams = Global.Settings;
  35.             
  36.             if (!IsPostBack) 
  37.             {
  38.                 Schedule scheduleHelper = Global.Schedule;
  39.                 Programme programme = null;
  40.                 currentlyRecording.Visible = false;
  41.                 updateEndTime.Checked = false;
  42.                 newEndTime.Visible = false;
  43.                 // if this show was already scheduled, view=cancel would have been passed in
  44.                 ScheduledRecording scheduledRecording = null;
  45.                 if (Request.Params["rid"] != null)
  46.                 {                
  47.                     recordingOptionsPanel.Visible = false;
  48.                     spanRecordCancel.InnerText = "Recording Not Found!";
  49.                     lnkRecordCancel.CommandName = "cancel";
  50.                     //Since we are looking at a recorded show the user should be able to see the Stream Now button
  51.                     streamNow.Visible = true;
  52.  
  53.                     scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  54.  
  55.                     if (scheduledRecording != null)
  56.                     {
  57.                         prePadding.Text = scheduledRecording.getPrePadMinutes().ToString();
  58.                         postPadding.Text = scheduledRecording.getPostPadMinutes().ToString();
  59.  
  60.                         watchLink.HRef = Download.GetDownloadUrl(false, false, Convert.ToInt32(Request.Params["rid"]));
  61.                         watchLink.Visible = false;
  62.                         // reload recording list
  63.                         string recorded_quality;
  64.                         switch (scheduledRecording.getQualitySetting())
  65.                         {
  66.                             case (int)Schedule.Quality.Low:
  67.                                 recorded_quality = "Low";
  68.                                 newQuality.SelectedValue = "Low";
  69.                                 break;
  70.                             case (int)Schedule.Quality.Medium:
  71.                                 recorded_quality = "Medium";
  72.                                 newQuality.SelectedValue = "Medium";
  73.                                 break;
  74.                             case (int)Schedule.Quality.High:
  75.                                 recorded_quality = "High";
  76.                                 newQuality.SelectedValue = "High";
  77.                                 break;
  78.                             case (int)Schedule.Quality.Custom1:
  79.                                 recorded_quality = "Custom 1";
  80.                                 newQuality.SelectedValue = "Custom1";
  81.                                 break;
  82.                             case (int)Schedule.Quality.Custom2:
  83.                                 recorded_quality = "Custom 2";
  84.                                 newQuality.SelectedValue = "Custom2";
  85.                                 break;
  86.                             case (int)Schedule.Quality.LiveTV:
  87.                                 recorded_quality = "LiveTV";
  88.                                 newQuality.SelectedValue = "LiveTV";
  89.                                 break;
  90.                             default:
  91.                                 recorded_quality = string.Empty;
  92.                                 break;
  93.                         }
  94.                         recordingQuality.Text = recorded_quality;
  95.                         switch (scheduledRecording.getRecordingStatus())
  96.                         {
  97.                             case ScheduledRecording.STATUS_PENDING:
  98.                                 lnkRecordCancel.CssClass = "btn-normal-large";
  99.                                 spanRecordCancel.InnerText = "Cancel Recording";
  100.                                 padStart.Text = Convert.ToString(scheduledRecording.getPrePadMinutes());
  101.                                 padEnd.Text = Convert.ToString(scheduledRecording.getPostPadMinutes());
  102.                                 currentlyRecording.Visible = true;
  103.                                 break;
  104.                             case ScheduledRecording.STATUS_IN_PROGRESS:
  105.                                 lnkRecordCancel.CssClass = "btn-normal-large-red";
  106.                                 spanRecordCancel.InnerText = "Cancel Recording";
  107.                                 padStart.Text = Convert.ToString(scheduledRecording.getPrePadMinutes());
  108.                                 padEnd.Text = Convert.ToString(scheduledRecording.getPostPadMinutes());
  109.                                 currentlyRecording.Visible = true;
  110.                                 watchLink.Visible = true;
  111.                                 break;
  112.                             case ScheduledRecording.STATUS_COMPLETED:
  113.                                 lnkRecordCancel.CssClass = "btn-normal-large-red";
  114.                                 spanRecordCancel.InnerText = "Delete Recording";
  115.                                 watchLink.Visible = true;
  116.                                 break;
  117.                             case ScheduledRecording.STATUS_COMPLETED_WITH_ERROR:
  118.                                 lnkRecordCancel.CssClass = "btn-normal-large-red";
  119.                                 spanRecordCancel.InnerText = "Delete Recording";
  120.                                 break;
  121.                             case ScheduledRecording.STATUS_CONFLICT:
  122.                                 lnkRecordCancel.CssClass = "btn-normal-large";
  123.                                 spanRecordCancel.InnerText = "Cancel Recording";
  124.                                 break;
  125.                             case ScheduledRecording.STATUS_PLACE_HOLDER:
  126.                                 lnkRecordCancel.CssClass = "btn-normal-large";
  127.                                 spanRecordCancel.InnerText = "Cancel Recording";
  128.                                 break;
  129.                             case ScheduledRecording.STATUS_DELETED:
  130.                                 lnkRecordCancel.CssClass = "btn-normal-large";
  131.                                 spanRecordCancel.InnerText = "Record This Episode";
  132.                                 break;
  133.                             default:
  134.                                 lnkRecordCancel.CssClass = "btn-normal-large";
  135.                                 spanRecordCancel.InnerText = "Unknown Status!";
  136.                                 break;
  137.                         }
  138.                     }
  139.  
  140.                     if (Request.Params["id"] != null)
  141.                     {
  142.                         programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
  143.                     }
  144.                     else
  145.                     {
  146.                         programme = null;
  147.                     }
  148.                 }
  149.                 else
  150.                 {
  151.                     recordingDetailsPanel.Visible = false;
  152.                     spanRecordCancel.InnerText = "Record This Episode";
  153.                     lnkRecordCancel.CommandName = "record";
  154.                     programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
  155.                     XmlNode pre = Global.Config.SelectSingleNode("/settings/PreShowPadding");
  156.                     XmlNode post = Global.Config.SelectSingleNode("/settings/PostShowPadding");
  157.                     prePadding.Text = pre.InnerText;
  158.                     postPadding.Text = post.InnerText;
  159.                 }
  160.  
  161.                 if (programme != null)
  162.                 {
  163.                     //check to see if the user has VLC installed to do streaming
  164.                     bool strmAllowed = File.Exists(Path.Combine(guideParams.strmVLCLoc, "vlc.exe"));
  165.                     if (strmAllowed)
  166.                     {
  167.                         //If the programme is in the current time period (it is airing now) or it was recorded previously then the user can Stream Now
  168.                         if ((programme.getStartTime() <= DateTime.Now &&
  169.                              programme.getEndTime() > DateTime.Now.AddMinutes(1)) ||
  170.                             (Request.Params["rid"] != null && programme.getStartTime() <= DateTime.Now))
  171.                         {
  172.                             streamNow.Visible = true;
  173.                         }
  174.                         else
  175.                         {
  176.                             streamNow.Visible = false;
  177.                         }
  178.                     }
  179.                     else
  180.                     {
  181.                         streamNow.Visible = false;
  182.                     }
  183.  
  184.                     // show programme details
  185.                     showTitle.Text = programme.getTitle();
  186.                     programUniqueIdentifier = programme.getUniqueProgrammeIdentifier();
  187.                     showSubTitle.Text = programme.getSubTitle();
  188.  
  189.                     string description = DetailDisplay.getDetailDisplay(programme);
  190.  
  191.                     showDescription.Text = description;
  192.  
  193.                     subTitlePanel.Visible = showSubTitle.Text.Length > 0;
  194.                     descriptionPanel.Visible = showDescription.Text.Length > 0;
  195.                     divUniqueID.Visible = programUniqueIdentifier.Length > 0;
  196.  
  197.                     showStartDate.Text = programme.getStartTime().ToLongDateString();
  198.                     //If the programme being viewed is already set to record or is recorded then we want to pull the end time
  199.                     //from the recording rather than how the program was listed on the EPG.
  200.                     if (scheduledRecording != null)
  201.                     {
  202.                         showTimes.Text = programme.getStartTime().ToShortTimeString() + " - " +
  203.                                          scheduledRecording.getEndTime().ToShortTimeString();
  204.                     }
  205.                     else
  206.                     {
  207.                         showTimes.Text = programme.getStartTime().ToShortTimeString() + " - " +
  208.                                          programme.getEndTime().ToShortTimeString();
  209.                     }
  210.  
  211.                     Channel channel = scheduleHelper.GetChannelByOID(programme.getChannelOID());
  212.                     string channelName = channel.getName();
  213.                     if (channelName.StartsWith(channel.getChannelNumber().ToString()))
  214.                         // cosmetic stuff for my american friends
  215.                     {
  216.                         channelName = channelName.Substring(channel.getChannelNumber().ToString().Length);
  217.                     }
  218.                     showChannel.Text = "<span class=\"channelnumber\"><b>" + channel.getChannelNumber() +
  219.                                        "</b></span> (<span class=\"channelname\"><nobr>" + channelName +
  220.                                        "</nobr></span>)";
  221.  
  222.                     //Set the default recording Quality
  223.                     quality.SelectedValue = guideParams.recordingQuality;
  224.                     TimeSpan span = programme.getStartTime() - DateTime.Now;
  225.                     if (span.Minutes >= 0)
  226.                     {
  227.                         reminderButton.Text = "<span>Set Reminder</span>";
  228.                         ArrayList reminders = scheduleHelper.GetReminderList();
  229.                         foreach (Programme pgm in reminders)
  230.                         {
  231.                             if (pgm.getOID() == programme.getOID())
  232.                             {
  233.                                 reminderButton.Text = "<span>Kill Reminder</span>";
  234.                             }
  235.                         }
  236.                     }
  237.                     else
  238.                     {
  239.                         reminderButton.Visible = false;
  240.                     }
  241.                 }
  242.                 else
  243.                 {
  244.                     streamNow.Visible = false;
  245.                     reminderButton.Visible = false;
  246.                     showStartDate.Text = "Season Recording";
  247.                     subTitlePanel.Visible = false;
  248.                     descriptionPanel.Visible = false;
  249.                     divUniqueID.Visible = false;
  250.                     recordingOptionsPanel.Visible = true;
  251.                     radioDay.Visible = false;
  252.                     radioTime.Visible = false;
  253.                     recordingsToKeep.Visible = false;
  254.  
  255.                     if (scheduledRecording != null)
  256.                     {
  257.                         checkedDays.Visible = true;
  258.  
  259.                         showTimes.Text = scheduledRecording.getStartTime().ToShortTimeString() + " - " +
  260.                                          scheduledRecording.getEndTime().ToShortTimeString();
  261.                         showTitle.Text = scheduledRecording.getFileName();
  262.  
  263.                         checkedDays.Enabled = false;
  264.  
  265.                         int day_mask = scheduleHelper.getSeasonDayMask(scheduledRecording);
  266.  
  267.                         if (day_mask != -1)
  268.                         {
  269.                             if ((day_mask & ReoccuringRecordingExtras.DAY_SUNDAY) > 0)
  270.                             {
  271.                                 checkedDays.Items[6].Selected = true;
  272.                             }
  273.  
  274.                             if ((day_mask & ReoccuringRecordingExtras.DAY_SATURDAY) > 0)
  275.                             {
  276.                                 checkedDays.Items[5].Selected = true;
  277.                             }
  278.  
  279.                             if ((day_mask & ReoccuringRecordingExtras.DAY_FRIDAY) > 0)
  280.                             {
  281.                                 checkedDays.Items[4].Selected = true;
  282.                             }
  283.  
  284.                             if ((day_mask & ReoccuringRecordingExtras.DAY_THURSDAY) > 0)
  285.                             {
  286.                                 checkedDays.Items[3].Selected = true;
  287.                             }
  288.  
  289.                             if ((day_mask & ReoccuringRecordingExtras.DAY_WEDNESDAY) > 0)
  290.                             {
  291.                                 checkedDays.Items[2].Selected = true;
  292.                             }
  293.  
  294.                             if ((day_mask & ReoccuringRecordingExtras.DAY_TUESDAY) > 0)
  295.                             {
  296.                                 checkedDays.Items[1].Selected = true;
  297.                             }
  298.  
  299.                             if ((day_mask & ReoccuringRecordingExtras.DAY_MONDAY) > 0)
  300.                             {
  301.                                 checkedDays.Items[0].Selected = true;
  302.                             }
  303.                         }
  304.                     }
  305.                     else
  306.                     {
  307.                         checkedDays.Visible = false;
  308.                         showTimes.Text = string.Empty;
  309.                         showTitle.Text = string.Empty;
  310.                     }
  311.  
  312.  
  313.                     spanRecordCancel.InnerText = "Update Season Recording";
  314.                     lnkRecordCancel.CommandName = "update";
  315.  
  316.                     Channel channel = scheduleHelper.GetChannelByOID(scheduledRecording.getChannelOID());
  317.                     string channelName = channel.getName();
  318.                     if (channelName.StartsWith(channel.getChannelNumber().ToString()))
  319.                     // cosmetic stuff for my american friends
  320.                     {
  321.                         channelName = channelName.Substring(channel.getChannelNumber().ToString().Length);
  322.                     }
  323.                     showChannel.Text = "<span class=\"channelnumber\"><b>" + channel.getChannelNumber() +
  324.                    "</b></span> (<span class=\"channelname\"><nobr>" + channelName +
  325.                    "</nobr></span>)";
  326.  
  327.                     switch ((Schedule.Quality)scheduledRecording.getQualitySetting())
  328.                     {
  329.                         case Schedule.Quality.High:
  330.                             quality.SelectedValue = "High";
  331.                             newQuality.SelectedValue = "High";
  332.                             break;
  333.  
  334.                         case Schedule.Quality.Medium:
  335.                             quality.SelectedValue = "Medium";
  336.                             newQuality.SelectedValue = "Medium";
  337.                             break;
  338.  
  339.                         case Schedule.Quality.Low:
  340.                             quality.SelectedValue = "Low";
  341.                             newQuality.SelectedValue = "Low";
  342.                             break;
  343.  
  344.                         case Schedule.Quality.Custom1:
  345.                             quality.SelectedValue = "Custom1";
  346.                             newQuality.SelectedValue = "Custom1";
  347.                             break;
  348.  
  349.                         case Schedule.Quality.Custom2:
  350.                             quality.SelectedValue = "Custom2";
  351.                             newQuality.SelectedValue = "Custom2";
  352.                             break;
  353.                     }
  354.  
  355.                     radioTime.Items[0].Enabled = false;
  356.                     if (scheduledRecording.getStartTime().Year != 0001)
  357.                     {
  358.                         radioTime.SelectedValue = "thisTime";
  359.                     }
  360.                     else
  361.                     {
  362.                         radioTime.SelectedValue = "anyTime";
  363.                     }
  364.  
  365.                     prePadding.Text = scheduledRecording.getPrePadMinutes().ToString();
  366.                     postPadding.Text = scheduledRecording.getPostPadMinutes().ToString();
  367.                 }
  368.  
  369.                 //Guest Users do not get access to initiatie, delete or cancel recordings. 
  370.                 lnkRecordCancel.Visible = Convert.ToBoolean((string) Session["NotGuestUser"]);
  371.                 if (Request.Params["rid"] != null && recordingOptionsPanel.Visible)
  372.                 {
  373.                     recordingOptionsPanel.Visible = Convert.ToBoolean((string) Session["NotGuestUser"]);
  374.                 }
  375.             }
  376.         }
  377.  
  378.         protected void lnkRecordCancel_Click(object sender, EventArgs e)
  379.         {
  380.             Schedule scheduleHelper = Global.Schedule;
  381.             Programme programme = null;
  382.             if (Request.Params["id"] != null && lnkRecordCancel.CommandName != "cancel")
  383.             {
  384.                 programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
  385.                 if (Convert.ToDouble(extendMinutes2.Text) != 0)
  386.                 {
  387.                     //Add the number of minutes that was entered to the end time of the recording to set the new end time
  388.                     DateTime newEndDate =
  389.                         programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes2.Text));
  390.                     //Set the new end time for the recording
  391.                     programme.setEndTime(newEndDate);
  392.                 }
  393.             }
  394.             bool scheduleReturn = true;
  395.             if (lnkRecordCancel.CommandName == "record")
  396.             {
  397.                 Schedule.Quality quality = 0;
  398.                 int prePad = Convert.ToInt32(prePadding.Text);
  399.                 int postPad = Convert.ToInt32(postPadding.Text);
  400.                 switch (Request.Params["quality"].ToLower())
  401.                 {
  402.                     case "high":
  403.                         quality = Schedule.Quality.High;
  404.                         break;
  405.  
  406.                     case "medium":
  407.                         quality = Schedule.Quality.Medium;
  408.                         break;
  409.  
  410.                     case "low":
  411.                         quality = Schedule.Quality.Low;
  412.                         break;
  413.  
  414.                     case "custom1":
  415.                         quality = Schedule.Quality.Custom1;
  416.                         break;
  417.  
  418.                     case "custom2":
  419.                         quality = Schedule.Quality.Custom2;
  420.                         break;
  421.                 }
  422.  
  423.                 if (radioTime.SelectedValue == "once")        
  424.                 {
  425.                     // schedule one-off recording
  426.                     Schedule myschedule = Global.Schedule;
  427.                     scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
  428.                     if (scheduleReturn)
  429.                     {
  430.                         // build up a list of the recording we already know about
  431.                         IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  432.                         if (!knownRecordings.Contains(programme.getOID()))
  433.                         {
  434.                             scheduleReturn = false;
  435.                         }
  436.                     }
  437.                 }
  438.                 else
  439.                 {
  440.                     //Schedule Season Recordings
  441.                     //Set the max number of recordings to keep for the show
  442.                     int keepnumRecordings     = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  443.                     if (keepRecordings.Text.ToString() != null)
  444.                     {
  445.                         try
  446.                         {
  447.                             keepnumRecordings     = Convert.ToInt32(keepRecordings.Text);
  448.                         }
  449.                         catch
  450.                         {
  451.                             keepnumRecordings     = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  452.                         }
  453.                     }
  454.                     else
  455.                     {
  456.                         keepnumRecordings     = ReoccuringRecordingExtras.KEEP_ALL_FILES;
  457.                     }
  458.                     
  459.                     Schedule myschedule = Global.Schedule;
  460.  
  461.                     if (radioTime.SelectedValue == "thisTime")
  462.                     {
  463.                         // schedule season recording for any day and this time
  464.                         if (radioDay.SelectedValue == "anyDay")
  465.                         {
  466.                             scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
  467.                             if (scheduleReturn)
  468.                             {
  469.                                 // build up a list of the recording we already know about
  470.                                 IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  471.                                 if (!knownRecordings.Contains(programme.getOID()))
  472.                                 {
  473.                                     scheduleReturn = false;
  474.                                 }
  475.                             }
  476.                         }
  477.                         // schedule season recording for only this day and this time
  478.                         else if (radioDay.SelectedValue == "thisDay")
  479.                         {
  480.                             scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
  481.                             if (scheduleReturn)
  482.                             {
  483.                                 // build up a list of the recording we already know about
  484.                                 IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  485.                                 if (!knownRecordings.Contains(programme.getOID()))
  486.                                 {
  487.                                     scheduleReturn = false;
  488.                                 }
  489.                             }
  490.                         }
  491.                         // schedule season recording for the selected days and this time
  492.                         else
  493.                         {
  494.                             ArrayList dayList = new ArrayList();
  495.                             // Iterate through the Items collection of the checkedDays 
  496.                             // control and create the correct number for the season recording.
  497.                             for (int i=0; i<checkedDays.Items.Count; i++)
  498.                             {
  499.                                 if (checkedDays.Items[i].Selected)
  500.                                 {
  501.                                     switch (checkedDays.Items[i].Text)
  502.                                     {
  503.                                         case "Monday":
  504.                                             dayList.Add(Schedule.Day.Monday);
  505.                                             break;
  506.                                         case "Tuesday":
  507.                                             dayList.Add(Schedule.Day.Tuesday);
  508.                                             break;
  509.                                         case "Wednesday":
  510.                                             dayList.Add(Schedule.Day.Wednesday);
  511.                                             break;
  512.                                         case "Thursday":
  513.                                             dayList.Add(Schedule.Day.Thursday);
  514.                                             break;
  515.                                         case "Friday":
  516.                                             dayList.Add(Schedule.Day.Friday);
  517.                                             break;
  518.                                         case "Saturday":
  519.                                             dayList.Add(Schedule.Day.Saturday);
  520.                                             break;
  521.                                         case "Sunday":
  522.                                             dayList.Add(Schedule.Day.Sunday);
  523.                                             break;
  524.                                     }
  525.                                 }
  526.                             }
  527.                             scheduleReturn = myschedule.ScheduleThisTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
  528.                             if (scheduleReturn)
  529.                             {
  530.                                 // build up a list of the recording we already know about
  531.                                 IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  532.                                 if (!knownRecordings.Contains(programme.getOID()))
  533.                                 {
  534.                                     scheduleReturn = false;
  535.                                 }
  536.                             }
  537.                         }
  538.                     }
  539.                     else
  540.                     {
  541.                         // schedule season recording for any day any time
  542.                         if (radioDay.SelectedValue == "anyDay")
  543.                         {
  544.                             scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleAnyDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
  545.                             if (scheduleReturn)
  546.                             {
  547.                                 // build up a list of the recording we already know about
  548.                                 IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  549.                                 if (!knownRecordings.Contains(programme.getOID()))
  550.                                 {
  551.                                     scheduleReturn = false;
  552.                                 }
  553.                             }
  554.                         }
  555.                             // schedule season recording for only this day and this time
  556.                         else if (radioDay.SelectedValue == "thisDay")
  557.                         {
  558.                             scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleThisDay, keepnumRecordings, Schedule.RecType.Season, prePad, postPad);
  559.                             if (scheduleReturn)
  560.                             {
  561.                                 // build up a list of the recording we already know about
  562.                                 IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  563.                                 if (!knownRecordings.Contains(programme.getOID()))
  564.                                 {
  565.                                     scheduleReturn = false;
  566.                                 }
  567.                             }
  568.                         }
  569.                             // schedule season recording for the selected days and this time
  570.                         else
  571.                         {
  572.                             ArrayList dayList = new ArrayList();
  573.                             // Iterate through the Items collection of the checkedDays 
  574.                             // control and create the correct number for the season recording.
  575.                             for (int i=0; i<checkedDays.Items.Count; i++)
  576.                             {
  577.                                 if (checkedDays.Items[i].Selected)
  578.                                 {
  579.                                     switch (checkedDays.Items[i].Text)
  580.                                     {
  581.                                         case "Monday":
  582.                                             dayList.Add(Schedule.Day.Monday);
  583.                                             break;
  584.                                         case "Tuesday":
  585.                                             dayList.Add(Schedule.Day.Tuesday);
  586.                                             break;
  587.                                         case "Wednesday":
  588.                                             dayList.Add(Schedule.Day.Wednesday);
  589.                                             break;
  590.                                         case "Thursday":
  591.                                             dayList.Add(Schedule.Day.Thursday);
  592.                                             break;
  593.                                         case "Friday":
  594.                                             dayList.Add(Schedule.Day.Friday);
  595.                                             break;
  596.                                         case "Saturday":
  597.                                             dayList.Add(Schedule.Day.Saturday);
  598.                                             break;
  599.                                         case "Sunday":
  600.                                             dayList.Add(Schedule.Day.Sunday);
  601.                                             break;
  602.                                     }
  603.                                 }
  604.                             }
  605.                             scheduleReturn = myschedule.ScheduleAnyTime(programme, quality, Schedule.DayType.SheduleSpecificDays, keepnumRecordings, dayList, Schedule.RecType.Season, prePad, postPad);
  606.                             if (scheduleReturn)
  607.                             {
  608.                                 // build up a list of the recording we already know about
  609.                                 IDictionary knownRecordings = scheduleHelper.LoadKnownRecordings();
  610.                                 if (!knownRecordings.Contains(programme.getOID()))
  611.                                 {
  612.                                     scheduleReturn = false;
  613.                                 }
  614.                             }
  615.                         }
  616.                     }
  617.                 }
  618.  
  619.                 if (scheduleReturn)
  620.                 {
  621.                     // close popup details window
  622.                     Page.RegisterStartupScript("startupScript", "<script language=JavaScript>reloadAndClose();</script>");
  623.                 }
  624.                 else
  625.                 {
  626.                     RecordMessage.Text = "Recording Failed!";
  627.                     RecordMessage.Visible = true;
  628.                 }
  629.             }
  630.             else if (lnkRecordCancel.CommandName == "cancel")
  631.             {
  632.                 ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  633.                 if (scheduledRecording != null)
  634.                 {
  635.                     scheduleHelper.CancelScheduledRecording(scheduledRecording);
  636.                 }
  637.                 Page.RegisterStartupScript("startupScript", "<script language=JavaScript>reloadAndClose();</script>");
  638.             }
  639.             else if (lnkRecordCancel.CommandName == "update")
  640.             {
  641.                 //Create a scheduled recording object of the programme being viewed so we have something to modify
  642.                 ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  643.  
  644.                 //Set the pre and post padding minutes
  645.                 scheduledRecording.setPrePadMinutes(Convert.ToInt32(prePadding.Text));
  646.                 scheduledRecording.setPostPadMinutes(Convert.ToInt32(postPadding.Text));
  647.  
  648.                 //Set the quality
  649.                 Schedule.Quality quality = 0;
  650.                 switch (Request.Params["quality"].ToLower())
  651.                 {
  652.                     case "high":
  653.                         quality = Schedule.Quality.High;
  654.                         break;
  655.  
  656.                     case "medium":
  657.                         quality = Schedule.Quality.Medium;
  658.                         break;
  659.  
  660.                     case "low":
  661.                         quality = Schedule.Quality.Low;
  662.                         break;
  663.  
  664.                     case "custom1":
  665.                         quality = Schedule.Quality.Custom1;
  666.                         break;
  667.  
  668.                     case "custom2":
  669.                         quality = Schedule.Quality.Custom2;
  670.                         break;
  671.                 }
  672.                 scheduledRecording.setQualitySetting((int) quality);
  673.  
  674.                 //Use the API to update the recording on the database
  675.                 scheduleHelper.UpdateScheduledRecording(scheduledRecording);
  676.  
  677.                 //Close the window
  678.                 Page.RegisterStartupScript("startupScript", "<script language=JavaScript>windowClose();</script>");
  679.             }
  680.         }
  681.  
  682.         private void getTheme()
  683.         {
  684.             string theme = Convert.ToString(Session["theme"]);
  685.  
  686.             if (theme != null && theme != "")
  687.             {
  688.                 return;
  689.             }
  690.             else
  691.             {
  692.                 HttpCookie cookie = Request.Cookies["theme"];
  693.                 if (cookie != null && cookie.Value.Length > 0)
  694.                 {
  695.                     theme = cookie.Value;
  696.                 }
  697.                 else
  698.                 {
  699.                     theme = "Default";
  700.                 }
  701.                 Session["theme"] = "themes/" + theme;
  702.                 return;
  703.             }
  704.         }
  705.  
  706.         #region Web Form Designer generated code
  707.         override protected void OnInit(EventArgs e)
  708.         {
  709.             //
  710.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  711.             //
  712.             InitializeComponent();
  713.             base.OnInit(e);
  714.         }
  715.         
  716.         /// <summary>
  717.         /// Required method for Designer support - do not modify
  718.         /// the contents of this method with the code editor.
  719.         /// </summary>
  720.         private void InitializeComponent()
  721.         {
  722.         }
  723.         #endregion
  724.  
  725.         protected void LinkButton1_Click(object sender, EventArgs e)
  726.         {
  727.             Schedule scheduleHelper = Global.Schedule;
  728.             ScheduledRecording scheduledRecording_check = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  729.             if (scheduledRecording_check == null)
  730.             {
  731.                 Programme programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
  732.                 if (Convert.ToDouble(extendMinutes2.Text) != 0)
  733.                 {
  734.                     //Add the number of minutes that was entered to the end time of the recording to set the new end time
  735.                     DateTime newEndDate =
  736.                         programme.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes2.Text));
  737.                     //Set the new end time for the recording
  738.                     programme.setEndTime(newEndDate);
  739.                 }
  740.                 bool scheduleReturn = true;
  741.                 Schedule.Quality quality = 0;
  742.                 int prePad = Convert.ToInt32(prePadding.Text);
  743.                 int postPad = Convert.ToInt32(postPadding.Text);
  744.  
  745.                 switch (Request.Params["quality"].ToLower())
  746.                 {
  747.                     case "high":
  748.                         quality = Schedule.Quality.High;
  749.                         break;
  750.  
  751.                     case "medium":
  752.                         quality = Schedule.Quality.Medium;
  753.                         break;
  754.  
  755.                     case "low":
  756.                         quality = Schedule.Quality.Low;
  757.                         break;
  758.  
  759.                     case "custom1":
  760.                         quality = Schedule.Quality.Custom1;
  761.                         break;
  762.  
  763.                     case "custom2":
  764.                         quality = Schedule.Quality.Custom2;
  765.                         break;
  766.                 }
  767.  
  768.                 Schedule myschedule = Global.Schedule;
  769.                 scheduleReturn = myschedule.ScheduleOnce(programme, quality, prePad, postPad);
  770.  
  771.                 if (scheduleReturn)
  772.                 {
  773.                     Thread.Sleep(5000);
  774.                     IList myScheduledRecordings = scheduleHelper.LoadRecordingSchedule();
  775.                     foreach (ScheduledRecording scheduledRecording in myScheduledRecordings)
  776.                     {
  777.                         if (scheduledRecording.getProgrammeOID() == programme.getOID())
  778.                         {
  779.                             Response.Redirect("public/Player.aspx?rid=" + scheduledRecording.getOID() + "&type=sn");
  780.                             break;
  781.                         }
  782.                     }
  783.                     RecordMessage.Text = "Stream Now Failed!";
  784.                     RecordMessage.Visible = true;
  785.                 }
  786.                 else
  787.                 {
  788.                     RecordMessage.Text = "Stream Now Failed!";
  789.                     RecordMessage.Visible = true;
  790.                 }
  791.             }
  792.             else
  793.             {
  794.                 Response.Redirect("public/Player.aspx?rid=" + scheduledRecording_check.getOID() + "&type=mr");
  795.             }
  796.         }
  797.         protected void updateEndTime_CheckedChanged(object sender, EventArgs e)
  798.         {
  799.  
  800.             //Logic that shows and hides the area for entering number of minutes to extend a recording
  801.             if (newEndTime.Visible == false)
  802.             {
  803.                 newEndTime.Visible = true;
  804.             }
  805.             else
  806.             {
  807.                 newEndTime.Visible = false; 
  808.             }
  809.             
  810.         }
  811.  
  812.         protected void reminderButton_Click(object sender, EventArgs e)
  813.         {
  814.             Schedule scheduleHelper = Global.Schedule;
  815.             Programme programme = null;
  816.             programme = scheduleHelper.GetProgrammeByOID(int.Parse(Request.Params["id"]));
  817.             if (reminderButton.Text == "<span>Set Reminder</span>")
  818.             {
  819.                 scheduleHelper.CreateReminder(programme);
  820.                 reminderButton.Text = "<span>Kill Reminder</span>";
  821.             }
  822.             else
  823.             {
  824.                 scheduleHelper.RemoveReminder(programme);
  825.                 reminderButton.Text = "<span>Set Reminder</span>"; 
  826.             }
  827.         }
  828.  
  829.         protected void endTimeUpdate_Click(object sender, EventArgs e)
  830.         {
  831.             //Create a new schedulehelper
  832.             Schedule scheduleHelper = Global.Schedule;
  833.             
  834.             //Create a scheduled recording object of the programme being viewed so we have something to modify
  835.             ScheduledRecording scheduledRecording = scheduleHelper.GetScheduledRecordingByOID(Convert.ToInt32(Request.Params["rid"]));
  836.             
  837.             //Set the pre and post padding minutes
  838.             scheduledRecording.setPrePadMinutes(Convert.ToInt32(padStart.Text));
  839.             scheduledRecording.setPostPadMinutes(Convert.ToInt32(padEnd.Text));
  840.  
  841.             //Add the number of minutes that was entered to the end time of the recording to set the new end time
  842.             DateTime newEndDate = scheduledRecording.getEndTime().AddMinutes(Convert.ToDouble(extendMinutes.Text));
  843.             //Set the new end time for the recording
  844.             scheduledRecording.setEndTime(newEndDate);
  845.  
  846.             //Set the quality to the new setting
  847.             Schedule.Quality Newquality = 0;
  848.             switch (newQuality.SelectedValue.ToLower())
  849.             {
  850.                 case "high":
  851.                     Newquality = Schedule.Quality.High;
  852.                     break;
  853.  
  854.                 case "medium":
  855.                     Newquality = Schedule.Quality.Medium;
  856.                     break;
  857.  
  858.                 case "low":
  859.                     Newquality = Schedule.Quality.Low;
  860.                     break;
  861.  
  862.                 case "custom1":
  863.                     Newquality = Schedule.Quality.Custom1;
  864.                     break;
  865.  
  866.                 case "custom2":
  867.                     Newquality = Schedule.Quality.Custom2;
  868.                     break;
  869.             }
  870.  
  871.             scheduledRecording.setQualitySetting((int)Newquality);
  872.             
  873.             //Use the API to update the recording on the database
  874.             scheduleHelper.UpdateScheduledRecording(scheduledRecording);
  875.             
  876.             //Close the window
  877.             ClientScript.RegisterStartupScript(typeof(String), "startupScript", "<script language=JavaScript>windowClose();</script>", false);
  878.         }
  879. }
  880. }
  881.